package frsf.cidisi.exercise.modelo.search;

import java.util.ArrayList;
import java.util.List;

import frsf.cidisi.exercise.modelo.util.Coordenada;
import frsf.cidisi.exercise.modelo.util.Laberinto;
import frsf.cidisi.exercise.modelo.util.Salida;
import frsf.cidisi.faia.agent.Action;
import frsf.cidisi.faia.environment.Environment;

public class Ambiente extends Environment {

    public Ambiente() {
        // Create the environment state
        this.environmentState = new AmbienteEstado();
    }

    @Override
	public AmbienteEstado getEnvironmentState() {
        return (AmbienteEstado) super.getEnvironmentState();
    }

    /**
     * This method is called by the simulator. Given the Agent, it creates
     * a new perception reading, for example, the agent position.
     * @param agent
     * @return A perception that will be given to the agent by the simulator.
     */
    @Override
    public  AgentePerception getPercept() {
        // Create a new perception to return
         AgentePerception perception = new AgentePerception();
		
         AmbienteEstado ambiente = this.getEnvironmentState();
         
		//TODO : Set the perceptions sensors
         Laberinto laberinto = new Laberinto(ambiente.getLaberinto().getCeldas());
         perception.setLaberinto(laberinto);
         
         List<Coordenada> listaEntradas = new ArrayList<Coordenada>(ambiente.getListaEntradas());
         perception.setListaEntradas(listaEntradas);
         
         List<Coordenada> listaLlaves = new ArrayList<Coordenada>(ambiente.getListaLlaves());
         perception.setListaLlaves(listaLlaves);
        
         List<Salida> listaSalidas = new ArrayList<Salida>(ambiente.getListaSalidas());
         perception.setListaSalidas(listaSalidas);
         
        // Return the perception
        return perception;
    }

    
    @Override
	public String toString() {
        return environmentState.toString();
    }

    
    @Override
	public boolean agentFailed(Action actionReturned) {

    	AmbienteEstado envState = this.getEnvironmentState();

        // TODO: Complete Method        

        return false;
    }

	//TODO: Complete this section with agent-specific methods
    // The following methods are agent-specific:
    
    
}
